package com.sskj.qiangjin.ui;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


import com.sskj.qiangjin.R;

import java.util.List;

public class ArrowAdapter extends ArrayAdapter {

    private final LayoutInflater inflater;
    private final int res;
    private final List<String> list;

    public ArrowAdapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
        super(context, resource, objects);
        inflater = LayoutInflater.from(context);
        res = resource;
        list = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null)
            convertView = inflater.inflate(res, null);

        TextView text = (TextView) convertView.findViewById(R.id.tvTitle);
        text.setText(getItem(position));
        return convertView;
    }

    @Override
    public String getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }
}
